﻿using System;

namespace RayDen.Library.Core
{
    public class LowDiscrepancySequence : BaseQMCSequence
    {
        public override double NextDouble()
        {
            if (_base >= primes.Length - 2)
                while (_base >= primes.Length - 2)
                {
                    _base = (uint)System.Math.Abs((int)System.DateTime.UtcNow.Ticks >> 26);
                }
            //(uint) DateTime.UtcNow.Ticks
            return MC.VanDerCorput((uint)primes[_base++], _seed++);
        }

        public override float NextValue(int index)
        {
            if (_base >= primes.Length - 2)
                while (_base >= primes.Length - 2)
                {
                    _base = (uint)System.Math.Abs((int)System.DateTime.UtcNow.Ticks >> 26);
                }
            return MC.VanDerCorput(_base, (uint)index);
        }
    }
}